export namespace util {
    /**@private */
    let _gid = 1;

    /**获取一个全局唯一ID。*/
    export function getGID(): number {
        return _gid++;
    } 

    export function lerp(from, to, time) {
        return (to - from) * time + from
    }

    export function lerp2D(from: mw.Vector2, to: mw.Vector2, t: number) {
        return from.add(to.subtract(from).multiply(t))
    }

    // [0-1]
    export function pingPong(t: number):number {
        return Math.abs(t % 1 - 0.5) * 2
    }

    //cycle为一个周期
    export function shake(t:number,cycle:number) {
        let floor = Math.floor(t/cycle) % 2
        let ping = Math.abs((t+0.75) % 1 - 0.5) * 2;
        return Math.min(floor + ping, 1-(floor*0.5));
    }
}
